package com.java.pattern.celue;

import com.java.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：xuelei
 * @date ：Created in 2021/9/14 14:06
 * @description：使用策略模式
 * @modified By：
 * @version: $
 */
@RestController
@RequestMapping("/app")
public class UseDemo {

    @Autowired
    private ApplicationContext applicationContext;

    @RequestMapping("/useCelue")
    public R useCelue (String payMent){
        Pay bean = applicationContext.getBean(payMent, Pay.class);
        String pay = bean.pay();
        return R.ok(pay);
    }
}
